//


#import "NT_NoteDetaiViewController.h"
#import "NT_EditNoteViewController.h"

@interface NT_NoteDetaiViewController ()

@end

@implementation NT_NoteDetaiViewController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    PostNotifition(@"Hidden");
}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    PostNotifition(@"Appear");
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setnavBatTitle:@"Detail"];
    self.view.backgroundColor = [UIColor whiteColor];
    //
    __weak typeof(self) weakSelf = self;
    if (_model != nil ) {
        [self nt_setupLeftAndRightwrurSetting:@"Edit" block:^{
            NT_EditNoteViewController *vc = [[NT_EditNoteViewController alloc]init];
            UINavigationController *nvc = [[UINavigationController alloc]initWithRootViewController:vc];
            vc.model = weakSelf.model;
            [weakSelf presentViewController:nvc animated:YES completion:nil];
        }];
    }
    
    
    //
    [self createUIView];
}
//MARK:
- (void)createUIView {
    
    UILabel *timeLabel = [[UILabel alloc]init];
    timeLabel.textColor = [UIColor blackColor];
    timeLabel.font = FontPFRegular(kRelativeWidth(14));
    timeLabel.text = _dateStr;
    [self.view addSubview:timeLabel];
    [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_offset(UI_NAV_BAR_HEIGHT + kRelativeWidth(20));
        make.left.mas_offset(kRelativeWidth(30));
        make.height.mas_equalTo(kRelativeHeight(20));
    }];
    //
    UILabel *titleLabel = [[UILabel alloc]init];
    titleLabel.textColor = [UIColor lightGrayColor];
    titleLabel.font = FontPFRegular(kRelativeWidth(16));
    titleLabel.text = _titleStr;
    titleLabel.numberOfLines = 0;
    [self.view addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(timeLabel.mas_bottom).offset(kRelativeHeight(20));
        make.left.mas_equalTo(timeLabel);
        make.right.mas_offset(-kRelativeWidth(30));
    }];
    //
    UIImageView *img = [[UIImageView alloc]init];
    img.image = _imgs;
    img.contentMode = UIViewContentModeScaleAspectFit;
    [self.view addSubview:img];
    [img mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(titleLabel.mas_bottom).offset(kRelativeHeight(10));
        make.centerX.mas_equalTo(self.view);
        make.width.height.mas_equalTo(kMainScreenWidth-2);
        
    }];
    
    UIButton *button = [[UIButton alloc]init];
    [button setTitle:@"Finish" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(Action:) forControlEvents:UIControlEventTouchUpInside];
    button.layer.cornerRadius = 6;
    button.hidden = !_noShow;
    [button setBackgroundColor:RGB(233, 233, 253)];
    [self.view addSubview:button];
    [button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(titleLabel.mas_bottom).offset(kRelativeHeight(30));
        make.centerX.mas_equalTo(self.view);
        make.width.mas_equalTo(kRelativeWidth(100));
        make.height.mas_equalTo(kRelativeHeight(30));
    }];
    
}
//
- (void)Action:(UIButton*)btn {
    btn.hidden = YES;
    if ([self.delegate respondsToSelector:@selector(sendDataModel:)]) {
        [self.delegate sendDataModel:_Id];
    }
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
